﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web;
using System.Collections;

namespace KingSite.Library.Cache.WebCacheWrapper {
    public class WebCacheWrapper : ICache {
        public void Add(string key, object value) {
            HttpContext.Current.Cache[key] = value;
        }
        public void Add(string key, object value, int seconds) {
            HttpContext.Current.Cache.Add(key, value, null, DateTime.Now.AddSeconds(seconds), System.Web.Caching.Cache.NoSlidingExpiration, System.Web.Caching.CacheItemPriority.Default, null);
        }
        public object Get(string key) {
            object result = HttpContext.Current.Cache[key];
            return result;
        }
        public void Remove(string key) {
            HttpContext.Current.Cache.Remove(key);
        }
        public void Clear() {
            IDictionaryEnumerator CacheEnum = HttpContext.Current.Cache.GetEnumerator();
            while (CacheEnum.MoveNext()) {
                HttpContext.Current.Cache.Remove(CacheEnum.Key.ToString());
            }
        }
    }
}
